package com.howie.hmvc.scanner;

import java.lang.reflect.Method;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lombok.Getter;
import lombok.Setter;

import com.howie.hmvc.paramparse.AbsParamParse;

/**
 * 保存controller方法信息
 * @author dhz
 */
public class ActionInfo {

	//controller实例
	@Getter
	@Setter
	private Object doInstance;
	@Getter
	@Setter
	private Method method;
	@Setter
	private AbsParamParse[] params;
	
	/**
	 * 组装参数
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public Object[] assemParam(HttpServletRequest request,HttpServletResponse response) throws Exception{
		Object[] args = null;
		if(params != null){
			args = new Object[params.length];
			for(int i=0;i<params.length;i++){
				AbsParamParse p = params[i];
				if(p != null){
					args[i] = p.getParamter(request,response);
				}
			}
		}
		return args;
	}
	
}
